{include file="layout/layout" /}
<script type="text/javascript" charset="utf-8" src="__ROOT__public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__ROOT__public/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__ROOT__public/ueditor/lang/zh-cn/zh-cn.js"></script>
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>商品管理</h3>
                <h5>添加商品</h5>
            </div>
        </div>
    </div>
    <div id="explanation" class="explanation">
        <div id="checkZoom" class="title">
        <i class="fa fa-lightbulb-o"></i>
        <h4 title="提示相关设置操作时应注意的要点">操作提示</h4><span title="收起提示" id="explanationZoom"></span>
        </div>
        <ul>
        <li>必须选择商品分类</li>
        </ul>
    </div>
    <form action="goodsAdd?act=a" method='post' enctype="multipart/form-data" id="roleform">
    <div class="ncap-form-default">
        <dl class="row">
            <dt class="tit">
                <label>商品名称</label>
            </dt>
            <dd class="opt">
                <input class="input-txt" name="gd_name" datatype="*" nullmsg="请填写商品名称" type="text" maxlength='10'>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>商品价格</label>
            </dt>
            <dd class="opt">
                <input class="input-txt" name="gd_price" datatype="/\d/" nullmsg="请填写商品价格" errormsg="只能输入数字" type="text" maxlength='10'> 元
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>商品原价</label>
            </dt>
            <dd class="opt">
                <input class="input-txt" name="gd_old_price" type="text" maxlength='10' id='old'> 元
                <span class="Validform_checktip Validform_wrong" id='o_error' style='display:none'>只能输入数字</span>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>商品分类</label>
            </dt>
            <dd class="opt">
                <select name="gd_cate_id" id='cate'>
                    <option value="0">— 请选择 —</option>
                    {foreach $cates as $k=>$v}
                        <option value="{$v.sg_id}">{$v.sg_name}</option>
                    {/foreach}
                </select>
                <span class="Validform_checktip Validform_wrong" id='c_error' style='display:none'>请选择分类</span>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>状态</label>
            </dt>
            <dd class="opt">
                <div class="onoff">
                    <label for="is_distribut1" class="cb-enable"><span>上架</span></label>
                    <label for="is_distribut2" class="cb-disable"><span>下架</span></label>
                    <input id="is_distribut1" name="gd_status" value="1" type="radio" >
                    <input id="is_distribut2" name="gd_status" value="0" type="radio" >
                </div>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label class="code_url">商品图片</label>
            </dt>
            <dd class="opt">
                <input class="input-txt valid" name="image" type="file" datatype="*" nullmsg="商品图片必须上传">
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label>商品描述</label>
            </dt>
            <dd class="opt">
                <textarea class="span12 ckeditor" id="desc" name="gd_desc" datatype="*" nullmsg="商品描述不能为空"></textarea>
            </dd>
        </dl>
        <div class="bot"><button id="button" style="width:96px;height:35px;background: #4FC0E8;border-radius:5px;line-height:35px;text-align: center;color:#fff;border: 0;font-size: 15px;">确认提交</button></div>
    </div> 
    </form>
</div>
<script>
    $(document).ready(function() {
        $('#roleform').Validform({
            tiptype: 3,
            beforeSubmit: function (data) {
                var check = 1;
                // 原价可为空
                var old = $('#old').val();
                var res = /\d/;
                if(old && !res.test(old)){
                    $('#o_error').show();
                    check++;
                }else{
                    $('#o_error').hide();
                }
                // 分类必选
                if($('#cate').val() == 0){
                    $('#c_error').show();
                    check++;
                }else{
                    $('#c_error').hide();
                }
                if(check > 1){
                    return false;
                }else{
                    return true;
                }
            }
        });
    })

</script>
<script>
    //实例化文本编辑器
    var editor;
    $(function() {
        //具体参数配置在  editor_config.js 中
        var options = {
            zIndex: 999,
            initialFrameWidth: "80%",
            //初化宽度
            initialFrameHeight: 400,
            //初化高度
            focus: false,
            //初始化时，是否让编辑器获得焦点true或false
            maximumWords: 99999,
            removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',
            //允许的最大字符数 'fullscreen',
            pasteplain: false,
            //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
            autoHeightEnabled: true
        };
        editor = new UE.ui.Editor(options);
        editor.render("desc");
    });
</script>
</body></html>